package com.ant.business.system.mapper;

import com.ant.business.system.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 用户管理持久层
 *
 * @author
 * @description
 * @create 2021-03-22 14:25:56
 **/
@Mapper
public interface UserDao extends BaseMapper<User> {

    /**
     * 通过角色查询用户列表
     *
     * @param roleId
     * @param unitId
     * @return
     */
    @Select("select user.* from tb_user user " +
            " inner join tb_user_role userRole on user.user_id = userRole.user_id " +
            " where user.unit_id = #{unitId} and userRole.unit_id = #{unitId} and userRole.role_id = #{roleId}")
    List<User> getUserByRoleId(int roleId, int unitId);
}